﻿@model IEnumerable<LAVAA.DAL.User>

@{
    ViewBag.Title = "Users";
}

<h2>Index</h2>

<p>
    @*@Html.ActionLink("Create New", "Create")*@
    @Html.DialogFormLink("Create user", Url.Action("Create"), "Create user", Url.Action("Index"))
    @Html.ActionLink("Handle usergroups", "Index", "UserGroup")
</p>
@using (Html.BeginForm("Search","User",FormMethod.Get))    
{  
    <p>
        Username: @Html.TextBox("username", null, new { style="width:50px" })
        Firstname: @Html.TextBox("firstname", null, new { style="width:50px" })
        Lastname: @Html.TextBox("lastname", null, new { style="width:50px" })
        Group: @Html.TextBox("group", null, new { style="width:50px" })
        <input type="submit" value="Filter" />
    </p>
}
<table>
    <tr>
        <th>
            @Html.DisplayName("Firstname")
        </th>
        <th>
            @Html.DisplayName("Lastname")
        </th>
        <th>
            @Html.DisplayName("Username")
        </th>
        <th>
            @Html.DisplayName("Administrator")
        </th>
        <th>
            @Html.DisplayName("Program responsible")
        </th>
        <th>
            @Html.DisplayName("Group")
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.FirstName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.LastName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UserId)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsAdministrator)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsProgramResponsible)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UserGroup.Name)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id = item.Id }, new { onclick = "return confirm('Are you sure you want to delete " + item.FirstName + "?')" })
            </td>
        </tr>
    }

</table>
